﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApFLEXSimulationPlayer
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands;

public class CApFLEXSimulationPlayer : ICApFLEXSimulationPlayer, IDisposable
{
  private readonly TxSimulationPlayer m_simulationPlayer;

  public CApFLEXSimulationPlayer(TxSimulationPlayer simulationPlayer)
  {
    this.m_simulationPlayer = simulationPlayer ?? throw new ArgumentNullException(nameof (simulationPlayer));
    this.m_simulationPlayer.Started += new TxSimulationPlayer_StartedEventHandler(this.SimulationPlayer_Started);
    this.m_simulationPlayer.SimulationStopped += new TxSimulationPlayer_SimulationStoppedEventHandler(this.SimulationPlayer_SimulationStopped);
  }

  public void Dispose()
  {
    this.m_simulationPlayer.Started -= new TxSimulationPlayer_StartedEventHandler(this.SimulationPlayer_Started);
    this.m_simulationPlayer.SimulationStopped -= new TxSimulationPlayer_SimulationStoppedEventHandler(this.SimulationPlayer_SimulationStopped);
  }

  public event CApCableEventHandler SimulationStarted;

  public event CApCableEventHandler SimulationStopped;

  public bool IsSimulationRunning() => this.m_simulationPlayer.IsSimulationRunning();

  private void SimulationPlayer_Started(object sender, TxSimulationPlayer_StartedEventArgs args)
  {
    CApCableEventHandler simulationStarted = this.SimulationStarted;
    if (simulationStarted == null)
      return;
    simulationStarted();
  }

  private void SimulationPlayer_SimulationStopped(
    object sender,
    TxSimulationPlayer_SimulationStoppedEventArgs args)
  {
    CApCableEventHandler simulationStopped = this.SimulationStopped;
    if (simulationStopped == null)
      return;
    simulationStopped();
  }
}
